const initialState = {
    data:[],
    dataChild:[],
    index:0
}

const reducer =  (state = initialState, { type, payload }) => {
    let newState = JSON.parse(JSON.stringify(state))

    switch (type) {

    case 'GET_LIST':
      newState.data=payload
      newState.dataChild=payload[0].children
      return newState
    case 'SET_INDEX':
      newState.dataChild = newState.data[payload].children
      return newState
      // case "CHECK_CHILDRENDATA":
      //       newState.dataChild = newState.data[payload].children
      //       return newState
    default:
      return newState
    }
}
export default reducer